<template>
  <div id="app">
    <h1>根组件</h1>
    <div>原来的数组: {{ list }}</div>
    <div>偶数数组: {{ filterList }}</div>
    <br>
    <input :value="count" type="text" @input="changeCount">
    <Son1></Son1>
    <hr>
    <Son2></Son2>
  </div>
</template>

<script>
import Son1 from './components/Son1.vue'
import Son2 from './components/Son2.vue'
import { mapState, mapGetters } from 'vuex'

export default {
  name: 'app',
  data() {
    return {

    }
  },
  computed: {
    ...mapState(['count', 'list']),
    ...mapGetters(['filterList'])
  },
  components: {
    Son1,
    Son2
  },
  created() {
    console.log('app', this.$store.state.count);
  },
  methods: {
    changeUserMsg() {
      this.$store.commit('changeUserMsg', { userName: '张三丰', userCity: '上海' })
    },
    changeCount(e) {
      this.$store.commit('changeCount', +e.target.value)
    }
  }
}
</script>

<style>
#app {
  width: 600px;
  margin: 20px auto;
  border: 3px solid #ccc;
  border-radius: 3px;
  padding: 10px;
}
</style>
